﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;

namespace PracaInz_v0
{
    class ForestButtonView : Button
    {
        public DrawTree TreeView { get; set; }
        TreeViewSettings _settings;
        int _id;

        public ForestButtonView(int id, DrawTree TreeView, object style, TreeViewSettings settings)
        {
            this.Width = 195;
            this.Height = 30;
            this.Content = "Tree " + (id + 1).ToString();
            this.Style = style as Style;
            this.TreeView = TreeView;
            this._settings = settings;
            this._id = id;

            this.Click += new RoutedEventHandler(ButtonListView_Click);
        }

        void ButtonListView_Click(object sender, RoutedEventArgs e)
        {
            _settings.SelectedTreeView = (this._id + 1).ToString();
            _settings.SliderValue = 1;
            ShowTreeView();           
        }

        async void ShowTreeView()
        {
            await Task.Run(() =>
                {
                    //przypisac canvas do viewbox            
                    this._settings.TreeView = null;
                    this._settings.TreeView = this.TreeView.TreeCanvas;
                });
        }
    }
}
